home *** CD-ROM | disk | FTP | other *** search
/ SGI Hot Mix 17 / Hot Mix 17.iso / HM17_SGI / research / lib / obsolete / gauss.pro < prev    next >
Text File  |  1997-07-08  |  954b  |  56 lines

  1. ; $Id: gauss.pro,v 1.2 1997/01/15 04:02:19 ali Exp $
  2. ;
  3. ;  Copyright (c) 1991-1997, Research Systems Inc.  All rights
  4. ;  reserved. Unauthorized reproduction prohibited.
  5.  
  6.  
  7. function gauss, a ;
  8. ;+
  9. ; NAME: 
  10. ;    GAUSS 
  11. ;
  12. ; PURPOSE: 
  13. ;    Gauss returns the cutoff value v such that
  14. ;
  15. ;        Probability(X > v) = a,
  16. ;
  17. ;    where X is a standard gaussian random variable.
  18. ; CATEGORY:
  19. ;    Statistics.
  20. ;
  21. ; CALLING SEQUENCE: 
  22. ;    Result = GAUSS(A)
  23. ;
  24. ; INPUT:
  25. ;    A:    The probability for which a cutoff is desired.
  26. ;
  27. ; OUTPUT: 
  28. ;    The cutoff value if a is beween 0 and 1 inclusively. Otherwise, -1.
  29. ;-
  30.  
  31. if (a gt 1 or a lt 0) then return,-1  
  32. if a eq 0 THEN return, 1.e12
  33. if a eq 1 THEN return,-1.e12
  34.  
  35. if (a gt .5) THEN BEGIN
  36.   a = 1-a
  37.   adjust = 1
  38. ENDIF ELSE adjust = 0 
  39.  
  40. BELOW = 0
  41. UP    = 1.0
  42.  
  43. while gaussint(UP) LT 1.0 - a DO BEGIN
  44.  Below = UP
  45.  UP = 2*UP
  46. ENDWHILE
  47.  
  48. x = pd_bisection([1.0-a],'gaussint',Up,Below)
  49. if adjust THEN BEGIN
  50.   a = 1 - a
  51.   return, -x
  52. ENDIF ELSE return,x
  53. end
  54.  
  55.